package com.dsbj.mp.icardservice.task.msgcenter;

import com.dsbj.mp.icardservice.entity.Employee;
import com.dsbj.mp.icardservice.service.EmployeeService;
import com.dsbj.mp.icardservice.service.msgcenter.McMessageService;
import com.dsbj.mp.icardservice.service.physicalcondition.DayPhysicalConditionService;
import com.dsbj.mp.icardservice.utils.listprocess.ListProcess;
import com.dsbj.mp.icardservice.utils.strprocess.StrUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 消息中心》定时任务。
 * @author cjw 2020-02-25
 */
@Component("taskMsgCenter")
@Transactional
@EnableScheduling
public class TaskMsgCenter {
	
	public static Logger logger= LoggerFactory.getLogger(TaskMsgCenter.class);
	
	@Resource
	private EmployeeService employeeService;
	
	@Resource
	private DayPhysicalConditionService dayPhysicalConditionService;
	
	@Resource
	private McMessageService mcMessageService;
	
	
	
	/**
	 * 消息中心》发送"健康打卡通知"。
	 * 若员工今天没有健康打卡,向其发送"健康打卡通知"。
	 * @param
	 * @return
	 * @author cjw 2020-02-25
	 */
	@Scheduled(cron = "0 30 11 * * ?")
	public void sendPhysicalConditonFillInRemind(){
		//获取所有在职员工的身份证号
		List<String> list_idcardno= employeeService.getEmployeeIdcardno();
		//获取"今日已打卡"的员工的身份证号
		List<String> list_idcardno_already= dayPhysicalConditionService.getDayPhysicalConditionIdcardnoByCheckTime_today();
		//从list_idcardno中清洗掉list_idcardno_already中的内容
		List<String> list_idcardno_washed= ListProcess.washList(list_idcardno,list_idcardno_already);
		
		//向list_idcardno_washed中的员工发送"健康打卡通知"
		mcMessageService.sendPhysicalConditionFillInRemindByIdcardno(list_idcardno_washed);
		logger.info("定时任务(0 30 11 * * ?): 若员工今天没有健康打卡,向其发送\"健康打卡通知\",已完成..");
	}


	
	/**
	 *
	 * @param
	 * @return
	 * @author cjw 2020-02-25
	 */
	public static void main(String[] args){
		
	}
}
